package com.thoughtworks.turtlemock;

import junit.framework.TestCase;

import com.thoughtworks.turtlemock.internal.ProxyTypeMock;

public class PublisherTest extends TestCase {

	private Publisher publisher;
	private Subscriber subscriber;
	private ProxyTypeMock subscriberMock;
	
	public void setUp() {
		subscriberMock = Turtle.mock(Subscriber.class);
		subscriber = (Subscriber) subscriberMock.mockTarget();
		publisher = new Publisher();
	}

	public void test_subscriber_should_receive_message_published_from_publisher_after_being_added() {
		publisher.add(subscriber);
		publisher.publish("Hello");
		subscriberMock.assertDid("receive").with("Hello");
	}
	
	public void test_subscriber_should_not_receive_any_message_from_publisher_if_have_not_been_added() {
		publisher.publish("Hello");
		subscriberMock.assertNotDid("receive");
	}
}
